package com.youmingxing.dialog;

import android.content.Intent;
import android.os.Bundle;
import android.support.annotation.Nullable;
import android.support.v4.app.DialogFragment;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.TextView;

import com.youmingxing.R;
import com.youmingxing.activity.WebViewActivity;
import com.youmingxing.bean.Web;

/**
 * 私信时积分不足的弹窗提示
 */

public class PersonalMessageDialog extends DialogFragment implements View.OnClickListener {

    private int popularNum;

    @Override
    public void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setStyle(DialogFragment.STYLE_NORMAL, R.style.dialog_middle); // R.style.report_dialog
        Bundle bundle = getArguments();
        if (bundle != null) {
            popularNum = bundle.getInt("popularNum");
        }
    }

    @Override
    public View onCreateView(LayoutInflater inflater, ViewGroup container, @Nullable Bundle savedInstanceState) {
        View view = inflater.inflate(R.layout.personnal_message_dialog, container, false);

        initView(view);
        return view;
    }

    private void initView(View view) {
        TextView titleTV = (TextView) view.findViewById(R.id.message_hint_tv);
        titleTV.setText("你的人气值还不足" + popularNum);
        TextView cancleTv = (TextView) view.findViewById(R.id.cancle_tv);
        cancleTv.setOnClickListener(this);

        TextView getMethodTv = (TextView) view.findViewById(R.id.getmethod_tv);
        getMethodTv.setOnClickListener(this);


    }


    @Override
    public void onClick(View v) {
        switch (v.getId()) {
            case R.id.getmethod_tv:
                Intent intent = new Intent(getActivity(), WebViewActivity.class);
                intent.putExtra("web_page", Web.popularity);
                startActivity(intent);
                dismiss();
                break;
            case R.id.cancle_tv:
                dismiss();
                break;
        }
    }
}
